Lab Exercise 1

Objective: Build a calculator using Interface Builder, the Application Kit, and a skeleton calculator object.

Required files:
	Calculator.m	Contains implementation for the Calculator class (incomplete)
   	Calculator.h	Contains interface for the Calculator class
	Calc.nib 	User interface data (incomplete)
	Calc_main.m	Contains the main program to run the application (generated by Interface Builder)
   	Makefile	Creates the application via the "make" command (also generated by Interface Builder)
	IB.proj	Project specification for your application (contains info to generate Makefile, etc)
	Solution/	Directory containing one possible solution

Tasks:

1.	Study provided files to understand how they work and the initial methods available to you.

2. 	Double-click on Calc.nib to open Interface Builder, and build a calculator user interface:   
	a. 	Build the calculator interface. First create a window, then bring in buttons for the keypad 		and a TextField (not a ªField:º) for the display. 
	b. 	Use the Inspector window's ªAttributesº mode to set each digit button's tag to be equal to 		the digit. Also inspect the window to set its title and get rid of its buttons.
	c.	The Calc.nib file already contains an instance of the Calculator class (named 		CalculatorInstance, visible in the lower left corner of the screen). Connect each 		button to this instance, selecting the appropriate actions in the Inspector window.  To form 		a connection, you need to first hold the control key down, then click on the source and 		drag a line to the target. Then select the appropriate action in the ªActionsº column of the 		Inspector window and click ªConnect.º
	d.	Finally connect the outlets of CalculatorInstance. Form a connection from the object 		to your outlet, then select the appropriate outlet name in the ªOutletsº column of the 		Inspector window and click ªConnect.º  Connect the outlets (named aWindow and 		viewer)  to your  main window and the text field, respectively. 
	e. 	Remember to save your interface file. The project file (IB.proj),  Makefile,  and main 		program file (Calc_main.m) have been provided for you; all you need to do is select 		ªSaveº to save the .nib file. 

3.	Compile the application (type ``make debug'' in a Shell or Terminal, or, better yet, select 	ªMakeº from ªFileº menu of Interface Builder). Then run your program (type ªCalcº in a Shell or 	Terminal or double-click on the application icon in a Workspace window).   Digits, add, enter, 	and clear should work.  If not, back to step 2.

4.	To make other buttons work, add missing code to Calculator.m, add necessary methods 	in the Inspector window, and associate the buttons with the methods.

5.	[Optional] Fill in the stackError: method.  Add any corequisite code to other methods.

6.	[Optional] Customize calculator to your taste, and add additional functions.  Suggestions: 1/x, 	log, ln, sin, cos, tan, sqrt, y^x, exp.  (If unfamiliar with the UNIX math library, check out the 	manual page for ªmath.º)